package com.thams.entity;

import java.util.List;

/**
 * 瀛樿揣鍒嗙被 InventoryClass entity.
 * 
 * @author MyEclipse Persistence Tools
 */
public class InventoryClass implements java.io.Serializable {

	// Fields

	private static final long serialVersionUID = 1L;
	/** 存货父类编码 */
	private String parentCinvCcode;
	/** 存货大类编码 */
	private String cinvCcode;
	/** 存货大类名称 */
	private String cinvCname;
	/** 编码级次 */
	private Short iinvCgrade;
	/** 是否末级 */
	private Byte binvCend = 1;//默认添加的就是最后一级
	/** 所属经济分类编码 */
	private String cecoCode;
	/** 对应条形码编码 */
	private String cbarCode;
	/** 时间戳 */
	private String pubufts;
	private List<InventoryClass> children;

	// Constructors

	public List<InventoryClass> getChildren() {
		return children;
	}

	public void setChildren(List<InventoryClass> children) {
		this.children = children;
	}

	// Property accessors

	public String getCinvCcode() {
		return this.cinvCcode;
	}

	public void setCinvCcode(String cinvCcode) {
		this.cinvCcode = cinvCcode;
	}

	public String getCinvCname() {
		return this.cinvCname;
	}

	public void setCinvCname(String cinvCname) {
		this.cinvCname = cinvCname;
	}

	public Short getIinvCgrade() {
		return this.iinvCgrade;
	}

	public void setIinvCgrade(Short iinvCgrade) {
		this.iinvCgrade = iinvCgrade;
	}

	public Byte getBinvCend() {
		return this.binvCend;
	}

	public void setBinvCend(Byte binvCend) {
		this.binvCend = binvCend;
	}

	public String getCecoCode() {
		return this.cecoCode;
	}

	public void setCecoCode(String cecoCode) {
		this.cecoCode = cecoCode;
	}

	public String getCbarCode() {
		return this.cbarCode;
	}

	public void setCbarCode(String cbarCode) {
		this.cbarCode = cbarCode;
	}

	public String getPubufts() {
		return pubufts;
	}

	public void setPubufts(String pubufts) {
		this.pubufts = pubufts;
	}

	public String toJSON() {
		StringBuilder sb = new StringBuilder("{\"property\":{");
		sb.append("\"id\":").append("\"" + cinvCcode + "\",");
		sb.append("\"name\":").append("\"" + cinvCcode+"-"+cinvCname + "\",");
		sb.append("\"binvCend\":").append("\"" + binvCend + "\"");
		// sb.append("\"iinvCgrade\":").append("\""+iinvCgrade+"\",");
		// sb.append("\"binvCend\":").append("\""+binvCend+"\",");
		// sb.append("\"cecoCode\":").append("\""+cecoCode+"\",");
		// sb.append("\"cbarCode\":").append("\""+cbarCode+"\",");
		// sb.append("\"pubufts\":").append("\""+pubufts+"\"");
		sb.append("}");
		if (children != null && children.size() > 0) {
			sb.append(",\"children\":[");
			for (int i = 0; i < children.size(); i++) {
				InventoryClass iv = children.get(i);
				sb.append(iv.toJSON());
				if (i != children.size() - 1) {
					sb.append(",");
				}
			}
			sb.append("]");
		}
		sb.append("}");
		return sb.toString();
	}
	public String toJSONForJQuery() {
		StringBuilder sb = new StringBuilder("{");
		sb.append("\"id\":").append("\"" + cinvCcode + "\",");
		sb.append("\"name\":").append("\"" + cinvCcode+"-"+cinvCname + "\",");
		sb.append("\"binvCend\":").append("\"" + binvCend + "\"");
		// sb.append("\"iinvCgrade\":").append("\""+iinvCgrade+"\",");
		// sb.append("\"binvCend\":").append("\""+binvCend+"\",");
		// sb.append("\"cecoCode\":").append("\""+cecoCode+"\",");
		// sb.append("\"cbarCode\":").append("\""+cbarCode+"\",");
		// sb.append("\"pubufts\":").append("\""+pubufts+"\"");
		if (children != null && children.size() > 0) {
			sb.append(",\"children\":[");
			for (int i = 0; i < children.size(); i++) {
				InventoryClass iv = children.get(i);
				sb.append(iv.toJSONForJQuery());
				if (i != children.size() - 1) {
					sb.append(",");
				}
			}
			sb.append("]");
		}
		sb.append("}");
		return sb.toString();
	}

	public String getParentCinvCcode() {
		return parentCinvCcode;
	}

	public void setParentCinvCcode(String parentCinvCcode) {
		this.parentCinvCcode = parentCinvCcode;
	}

}
